<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
    <title>test</title>
    <script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=e27195e43f8628bcda450fcf8f5ec924"></script>
    <style>
        html,
        body,
        #container {
            width: 100%;
            height: 100%;
        }
    </style>
</head>
<body>
<div id="container"></div>
<script>
    var map = new AMap.Map('container', {
        resizeEnable: true, //是否监控地图容器尺寸变化
        zoom:11, //初始化地图层级
        center: [116,25] //初始化地图中心点
    });

    var overlayGroup = new AMap.OverlayGroup();
    var markers=new Array();
    var arry=new Array();
    arry[0]=104;
    arry[1]=30;
    arry[2]=117;
    arry[3]=27;
    arry[4]=116;
    arry[5]=45;
    var marker={};
    for(var i=0;i<3;i++)
    {
        var marker="marker"+i;
        window[marker] = new AMap.Marker({

            position: new AMap.LngLat(arry[2*i],arry[2*i+1]),   // 经纬度对象，也可以是经纬度构成的一维数组[116.39, 39.9]
            title:''
        });
        markers[i]=window[marker];
        // 添加新的覆盖物到群组
        overlayGroup.addOverlay(window[marker]);
    }

    // 统一添加到地图实例上
    map.add(overlayGroup);
    //动态绑定事件
    for(var i=0;i<3;i++) {
        (function() {
            var p=i;
            markers[i].on('click', function () {
                alert(markers[p].getPosition());
            })
        })();
    }

</script>

</body>
</html>